package com.example.demo.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author hongjinhui
 */
@Mapper
public interface CollegeDao {

    /**
     * 查询所有学院名
     *
     * @return 所有学院名
     */
    @Select("SELECT DISTINCT college_name FROM hbut_class_schedule WHERE college_name <> '示例学院' AND `data` IS NOT NULL")
    List<String> queryAllCollegeName();

    /**
     * 查询学院对应年级， 如果该年级的课表均为空则不返回
     *
     * @param collegeName 学院名
     * @return 该学院所有年级
     */
    @Select(" SELECT DISTINCT grade FROM hbut_class_schedule WHERE college_name = #{collegeName}  AND `data` IS NOT NULL")
    List<String> queryAllGradeByCollegeName(@Param("collegeName") String collegeName);


    /**
     * 查询指定学院和年级下的所有班级，不返回data为空的班级
     *
     * @param collegeName 学院名
     * @param grade 年级
     * @return 所有班级
     */
    @Select("SELECT `name` FROM hbut_class_schedule WHERE college_name = #{collegeName} AND grade = #{grade} AND `data` IS NOT NULL AND `name` <> '示例班级'")
    List<String> queryAllClassByCollegeNameAndGrade(@Param("collegeName") String collegeName, @Param("grade") String grade);


    @Select("SELECT college_name FROM hbut_class_schedule WHERE `name` = #{className}")
    String getCollegeByClass(String className);
}
